package com.eascs.finance.admin.server.manager.impl;

import java.util.Date;

import org.springframework.stereotype.Repository;

import com.eascs.finance.admin.common.entity.Attachment;
import com.eascs.finance.admin.server.manager.IAttachmentManager;
import com.eascs.web.sso.User;
import com.eascs.web.sso.UserHolder;

@Repository
public class AttachmentManagerImpl extends BaseDao implements IAttachmentManager {

	

	@Override
	public String addAttachment(Attachment attachment) {
		
		User user = UserHolder.getUser();
		attachment.setUpdateDate(new Date());
		attachment.setCreateDate(new Date());
		if (user != null) {
			attachment.setCreator(UserHolder.getUser().getCode());
			attachment.setUpdator(UserHolder.getUser().getCode());
		}
		
		boolean flag = this.saveEntity(attachment);
		if (flag == true) {
			return attachment.getId();
		} else {
			return null;
		}
	}

	@Override
	public Attachment findAttachmentById(String id) {
		
		return this.getById(Attachment.class, id);
	}


}
